const initialState = {
  items: [],
};

// 根据Action 更新状态的纯函数。
const cartReducer = (state = initialState, action) => {
  // 根据不同的 action 类型来更新状态
  switch (action.type) {
    case "ADD_TO_CART":
      return {
        ...state,
        items: [...state.items, action.payload],
      };
    default:
      return state;
  }
};

export default cartReducer;
